from api.mod.modLoader import ModLoader
from basic.entiys.charts.Authority import Authority
from basic.entiys.charts.BaseCharts import BaseCharts
from framework.modfuncexecute import ModFuncExecute


class StringAuth2Instance:
    @classmethod
    def doit(cls, charts: BaseCharts):
        """
        将角色的字符串权能转化为权能类
        :param charts:
        """
        cls.modloader = ModLoader()
        cls.auth_path = cls.modloader.authority.get(charts.fields.authority)
        cls.modfuncexec = ModFuncExecute(function_path=cls.auth_path)

        cls.auth = cls.modfuncexec.funtionRun()
        charts.fields.authority_instance:Authority = cls.auth
